export class Debounce {
    static use(fn: Function, awit: number = 1000, immediate: boolean = false) {
        let timer: any
        return (...args: []) => {
            if (timer) clearInterval(timer)
            if (immediate) {
                if (!timer) fn.apply(this, args);
                timer = setTimeout(function () {
                    timer = null;
                }, awit)
            } else {
                timer = setTimeout(() => { fn.apply(this, args) }, awit)
            }
        }
    }
}